package gui.table;

import java.awt.Component;

import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 * @author Ann Raboschuk
 */
@SuppressWarnings("serial")
public class CustomTableCellRenderer extends JComboBox implements TableCellRenderer
{
   @SuppressWarnings("unchecked")
   @Override
   public Component getTableCellRendererComponent(JTable table, Object value,
         boolean isSelected, boolean hasFocus, int row, int column)
   {
      JComboBox items = (JComboBox) value;
      for (int i=0; i<items.getItemCount(); i++)
         this.addItem(items.getItemAt(i));
      setSelectedItem(items.getSelectedItem());
      if (isSelected)
         setBackground(table.getSelectionBackground());
      else
         setBackground(table.getBackground());
     return this;
   }
}
